package com.yunatt.service.impl;

import com.yunatt.mapper.MachineCommandMapper;
import com.yunatt.model.MachineCommandEntity;
import com.yunatt.service.MachineCommandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class MachineCommandServiceImpl implements MachineCommandService {

    @Autowired
    private MachineCommandMapper machineCommandMapper;
    @Override
    public void addMachineCommand(MachineCommandEntity machineCommand) {
        machineCommandMapper.insert(machineCommand);
    }

    @Override
    public void addGetOneUserCommand(int enrollId, int backupNum, String serialNum) {
        String message="{\"cmd\":\"getuserinfo\",\"enrollid\":"+enrollId+",\"backupnum\":"+ backupNum+"}";
        MachineCommandEntity machineCommand=new MachineCommandEntity();
        machineCommand.setContent(message);
        machineCommand.setName("getuserinfo");
        machineCommand.setStatus(0);
        machineCommand.setSendStatus(0);
        machineCommand.setErrCount(0);
        machineCommand.setSerial(serialNum);
        machineCommand.setGmtCrate(new Date());
        machineCommand.setGmtModified(new Date());

        machineCommandMapper.insert(machineCommand);
    }
}
